package test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class SearchAddress {
    public static void main(String[] args) {
        SearchAddress searchAddress = new SearchAddress();
        ArrayList<String> address = searchAddress.quickSearch("安", 1);
        address.forEach(
                v -> {
                    System.out.println(v);
                }
        );
    }
    public HashMap<String, Integer> address;
    public SearchAddress(){
        this.address = new HashMap<String,Integer>();
        this.address.put("福建",0);
        this.address.put("福南",0);
        this.address.put("福北",0);
        this.address.put("福州",1);
        this.address.put("仓山",1);
        this.address.put("晋安",1);
        this.address.put("鼓楼",1);
    }
    public ArrayList<String> quickSearch(String addressName, Integer level){
        ArrayList<String> quickAddress = new ArrayList<>();
        address.forEach(
                (k,v) -> {
                    if(k.contains(addressName)){
                        if(v == level){
                            quickAddress.add(k);
                        }
                    }
                }
        );
        return quickAddress;
    }
}
